// pages/scan_qr_suc/scan_qr_suc.js
var app = getApp()
Page({
  data: {
    starIndex: 5,
    content:'',
    venue_id:'',
    user_id:''
  },
  onLoad: function (options) {
    console.log(options)
    this.setData({
      venue_id:options.venue_id,
      user_id:options.user_id
    })
  },
  onChange(e) {
    const index = e.detail.index;
    this.setData({
      'starIndex': index
    })
  },
  getComment(e){
    var val = e.detail.detail.value;
    this.setData({
      content: val
    });  
  },
  submitComment(){
    let that = this
    if(this.data.content.length == 0)
    {
      wx.showToast({
        title: '请输入评论',
      })
      return;
    }
    wx.request({
      url: app.url + 'weiapp/api/comment',
      data:{
        venue_id:that.data.venue_id,
        user_id:that.data.user_id,
        content: that.data.content,
        starIndex:that.data.starIndex,
        fit_class:1
      },
      success:function(res){
        if(res.data.data == 1)
        {
          wx.showToast({
            title: '发布成功',
          }),
          setTimeout(function(){
            wx.switchTab({
              url: '../index/index',
            })
          },2000)
        }
      }
    })
  }  
})